import React from 'react';
import { connect } from 'dva';
import { ListView, Icon, Badge } from 'antd-mobile';
import avatar from '../../../../../framework/utils/avatar';
import styles from './partTimeMessage.css';
import date from '../../../../../framework/utils/date';
import cutStr from '../../../../../framework/utils/cutStr';

const parTimeMessageIcon = require('../../../../../icons/message/partTime-message-icon.png');

const PartTimeMessage = ({
  item={},
  onViewMember=()=>{},
  showLimit=()=>{},
}) => {
  // console.log('item',JSON.stringify(item));
  // const publishTime = date.delta(item.publishTime)

  return (
    <div key={item.id} >
      <div className={styles.content}>
        <div className={styles.avatar} onClick={() => showLimit(item.id)}>
          {avatar(item.typeName, parTimeMessageIcon)}
          {item.unreadedCount > 0 ? (
            <i className={styles.newMessageRedPoint}>
              {item.unreadedCount > 100 ? '99+' : item.unreadedCount}
            </i>
          ):''}
        </div>
        <div className={styles.detail} onClick={() => onViewMember(item.id)}>
          <div className={styles.item}>
            <div className={styles.name}>
              兼职小助手
            </div>
            <div className={styles.distance}>
              {item.latestUnreadedDate ? date.delta(item.latestUnreadedDate) : ""}
            </div>
          </div>
          <div className={styles.item}>
            <span style={{color:'#999999', fontSize:'0.75em'}}>
              你投递的兼职有最新的消息啦
            </span>
          </div>
        </div>
      </div>
    </div>
  );
};

export default connect()(PartTimeMessage);
